var sub_curry = function(fn) {
    var args = [].slice.call(arguments, 1) //add 该有的参数拿到
    return function() {
        //newArgs 代表的是完整的参数
       var newArgs = args.concat([].slice.call(arguments)) //[...arguments] , Array.from(arguments)
       fn.apply(this, newArgs)
    }
}


function curry(fn,length) {
    length = length || fn.length
    var slice = Array.prototype.slice

    return function () {
        if (arguments.length < length) {
            var combined = [fn].concat(slice.call(arguments)) //[fn,a,b]
          return  curry(sub_curry.apply(this, combined),length-arguments.length)
        }else {
            return fn.apply(this, arguments)
        }
    }
}


var fn = curry(function(a,b,c) {
    return [a,b,c]
})

console.log(fn('1','2','3'));//[ '1', '2', '3' ]
console.log(fn('1')('2','3'));